 <{extends file="<{$tempdir}>/member/member.html"}>   
 
 <{block name=extendjs}>
   <link rel="stylesheet"  href="<{$siteurl}>/templates/<{$tempdir}>/public/css/order_wmr_det.css">   

 <script type="text/javascript" language="javascript" src="<{$siteurl}>/templates/<{$tempdir}>/public/js/ajaxfileupload.js"> </script>
 <script type="text/javascript" language="javascript" src="<{$siteurl}>/templates/<{$tempdir}>/public/js/datepicker/WdatePicker.js"> </script>
 <{/block}>
 <{block name=membercenter}> 
 	<div class="mc-right box790"><!--mc-right-->
					<div class="manageBox margin_bottom"><!--manageBox-->
						<div class="title"><!--title-->
							<p class="yleft"><span class="colortip"></span>
							<span class="title_name"><b>订单管理</b></span></p>
						</div><!--title end-->

        <div class="searchTab">
                            <div class="tabTitleWarp clearfix" id="jifen-title">
                               <ul>	<li class="c"><h3 <{if $actiondo=='order'}> class="addborder"<{/if}>><a  href="<{ofunc type=url link="/order/usersorder"}>">餐厅订单</a></h3></li>
										<li class="c"><h3 <{if $actiondo=='ordermarket'}> class="addborder"<{/if}>><a href="<{ofunc type=url link="/order/usermorder"}>" style="color:#fff;">超市订单</a></h3></li>
										<li class="c"><h3 <{if $actiondo=='usersptorder'}> class="addborder"<{/if}>><a href="<{ofunc type=url link="/order/usersptorder"}>" style="color:#fff;">跑腿订单</a></h3></li>
								 
									</ul>
                            </div>
                            <div class="clear"></div>
         </div>


        <div style="background-color:#fff;border:1px solid #ccc;margin-bottom:10px;">
        	
        	<div class="m3-order-list-search">
										 
										<select class="searchstatus" id="orderdatediff" onchange="getOrders();">
											<option value="0" >当月订单</option>
											<option value="1" <{if $orderdatediff==1}>selected<{/if}>>历史订单</option>
										</select>

											<input type="hidden" id="ordertype" value="0">
										从 	<input type="text" class="searchtime" id="stime" value="<{$stime|date_format:"%Y-%m-%d"}>"  onFocus="WdatePicker({isShowClear:false,readOnly:true});"> 至 
											<input type="text" id="etime" class="searchtime" value="<{$etime|date_format:"%Y-%m-%d"}>"  onFocus="WdatePicker({isShowClear:false,readOnly:true});"> 
										
										<select class="searchstatus" id="orderstatus" onchange="getOrders();">
											<option value="0">订单状态</option>
											<option value="1" <{if $status==1}>selected<{/if}>>处理中</option>
											<option value="2" <{if $status==2}>selected<{/if}>>已完成</option>
										</select>
										
										
										
										
										<input type="image" src="/upload/shop/search.jpg" class="searchs" onclick="getOrders();">
									 
									</div>
        	
        	
        </div>


						<div class="mr-middle content"><!--mr-middle-->
							<div class="user-order m3-user-order"><!-- m3-user-order -->
								 
								 
 
								<div class="order-list m3-order-list"><!-- m3-order-list -->
									

									<div class="m3-order-list-view" id="m3-order-list">
										<table class="di_table">	<tbody>
										<tr>
											<th class="m3-olist1">订单号</th>  
											<th class="m3-olist2">订单商家</th>  
											<th class="m3-olist3">下单时间</th>		
											<th class="m3-olist4">订单总额</th>		
											<th class="m3-olist5">订单状态</th>	
											<th class="m3-olist6">完成时间</th>
											<th class="m3-olist7">操作</th>	
										</tr>	
										<{if count($list) > 0}>
										<{foreach from=$list item=items}>
										<tr >		
											<td><a href="#orderview" onclick="getOrderDetail(<{$items['id']}>);">
											<{$items['dno']}><{if $items['is_goshop']==1}><font color=red>预定</font><{/if}></a></td>		
											<td><a <{if $items['shoptype']==1}>href="<{ofunc type=url link="/market"}><{else}>
											
											
												<{if $items['is_goshop']!=1}>
												href="<{ofunc type=url link="/shop/index/id/<{$items['shopid']}>"}>"
												<{else}>
												href="<{ofunc type=url link="/plate/show/id/<{$items['shopid']}>"}>"
											
												<{/if}>
											
											<{/if}>  target="_blank" class="apanel"><{$items['shopname']}></a></td>		
											<td><{$items['addtime']|date_format:"%Y-%m-%d %H:%M"}></td>		
											<td><p>￥<{$items['allcost']}></p><p>
											<{if $items['paytype']=='0'}><{if $items['is_goshop']==1}>到店支付<{else}>餐到支付<{/if}><{else}>在线支付<{if $items['paystatus']==1}>(已付)<font color=red><{$backarray[$items['is_reback']]}></font><{else}>(<a href="<{ofunc type=url link="/site/waitpay/orderid/<{$items['id']}>"}>">立即支付</a>)<{/if}><{/if}></p></td>	
											<td class="money">
										<{$items['wuliuinfo']['statustitle']}>,<br />
											<{$items['wuliuinfo']['ststusdesc']}> 
 </td>	
											<td><{if $items['status'] ==3}> <{$items['suretime']|date_format:"%Y-%m-%d %H:%M"}><{else}>---<{/if}></td>		
											<td><a href="#orderview" class="apanel" onclick="getOrderDetail(<{$items['id']}>);">查看</a></td>	
										</tr>
								
										<{/foreach}>
										<{else}>
										<tr>
											<td colspan="7" align="center">
												 暂无数据
											</td>
										</tr>
									  <{/if}>
										</tbody></table>
								   <div class="clear"></div>
								 	   <div class="show_page"> 
								 	   	  <ul>
								 	   	    <{$pagecontent}>
								 	     	</ul>
								 	   </div>
								 		<div class="clear">	</div>
								</div>
								</div>
								
								
								
								
								
								
								
								
								
							</div>
						</div>
						
						
						
		 <div style="background-color:#fff;border:1px solid #ccc;margin-top:10px;display:none;" id="tempordershow">
		 	<a name="orderview" id="orderview"></a>
								<div class="m3-order-detail" id="m3-order-detail">
									
									
								</div>
		 </div>
						
						
						
						
						
						
						
						
						
						
						
						
				</div>
			</div>
			
			
			
			
			
			
			
<script id="trgoodlist" type="text/html"> 
<section class="usercenter-detail">
			
	<div class="order-card order-process" style="display:block;">
  <div class="order-content">
    <div class="order-dishes">
      <table>
        <thead>
          <tr>
            <th colspan="3" style="text-align:left;"> <a 
			<^%if(order.shoptype==1){%^> 
			href="<{ofunc type=url link="/market/shopshow/id/<^%=order.id%^>"}>"
			 <^%}%^>
			 <^%if(order.shoptype==0){%^> 
			href="<{ofunc type=url link="/shop/index/id/<^%=order.id%^>"}>"
			 <^%}%^>
			class="shop-name"><^%=order.shopname%^></a>
              <p class="pag"><span class=" "></span>订单号：<^%=order.dno%^></p>
              <p class="pag"><span class="ico sphone"></span>商家电话：<^%=order.shopphone%^></p>
              <p class="pag"><span class="ico kphone"></span>客服电话：<^%=order.litel%^></p></th>
          </tr>
        </thead>
        <tbody>
		
			<^%for(i = 0; i < orderdet.length; i ++) {%^>
          <tr data-node="dishes">
            <td style="text-align:left;" data-node="dish" data-origin="<^%=orderdet[i].goodsname%^>"><^%=orderdet[i].goodsname%^></td>
            <td><^%=orderdet[i].sum%^></td>
            <td class="text-right">￥<^%=(orderdet[i].goodscost)*(orderdet[i].goodscount)%^> </td>
          </tr>
         	  <^%}%^> 
			<^%if(order.is_goshop!=1){%^>  
			 <tr data-node="dishes">
            <td  style="text-align:left;">配送费 </td>
            <td></td>
            <td class="text-right">￥<^%=order.pscost%^></td>
			 
			</tr>
			 <tr data-node="dishes">
            <td  style="text-align:left;">打包费 </td>
            <td></td>
            <td class="text-right">￥<^%=order.bagcost%^></td>
			 
			</tr>
		  <^%}%^>	
         <tr data-node="dishes">
            <td  style="text-align:left;">积分抵扣 </td>
            <td></td>
            <td class="text-right"><^%=order.scoredown%^>个</td>
			 
			</tr>
			 <tr data-node="dishes">
            <td  style="text-align:left;">优惠金 </td>
            <td></td>
            <td class="text-right"><^%=order.yhjcost%^>(券)+<^%=order.cxcost%^>(促销)</td>
			 
			</tr>
			 
        </tbody>
      </table>
      <div class="order-price"> 总价：<span class="ft-red">￥<^%=order.allcost%^></span> </div>
      <div class="order-delivery">
        <div class="tp"> <span><^%=order.shopname%^></span> </div>
        <div class="receive-info"> <span>送餐地址：<^%=order.buyeraddress%^></span> <span>联系人：<^%=order.buyername%^></span> <span>电话：<^%=order.buyerphone%^></span> 
		<span>送达时间：<^%=order.posttime%^> </span> <span><^%=order.content%^></span> </div>
      </div>
    </div>
    <div class="order-info" data-node="order-info">
      <div class="delivery-info">
	  
	<div id="wuliustatus">
	  
	 	<^%for(j = 0; j < orderwuliustatus.length; j ++) {%^>	   
        <div class="delivery-snippet ">
          <div class="snippet-header nick-selected">
            <div class="round"></div>
            <div class="line-through "></div>
          </div>

          <div class="snippet-body ">
            <div class="status-msg"><^%=orderwuliustatus[j].statustitle%^></div>
            <div class="prompt"><^%=orderwuliustatus[j].ststusdesc%^></div>
            <div class="time"><^%=orderwuliustatus[j].addtime%^></div>
          </div>
        </div>
		 <^%}%^>	
	</div>  	 
	<^%if(order.paytype==1 && order.paystatus==0 &&order.status < 2){%^>	
		<div class="delivery-snippet ">
          <div class="snippet-header nick-selected">
            <div class="round"></div>
            <div class="line-through " style="bottom: -20px;"></div>
          </div>

          <div class="snippet-body ">
            <div class="status-msg">待支付</div>
            <div class="prompt">请在15分钟内完成支付</div>
            <div class="time"><^%=orderwuliustatus[0].addtime%^></div>
          </div>
        </div>
        <div class="delivery-snippet ">
          <div class="snippet-header nick-selected">
            <div class="round"></div>
			<div class="line-through " style="bottom: -20px;"></div>
          </div>
		  <a href="<{ofunc type=url link="/site/waitpay/orderid/<^%=order.id%^>"}>" >
          <div class="snippet-body non-prompt">
            <div class="status-msg">请继续支付</div>
            <div class="prompt"> </div>
           </div>
		  </a>
        </div>
        
  <^%}%^>	

 <div class="">
 <div class="order-operator" data-node="order-operator">
			  <div class="operator-btns">
 			 
 <^%if(order.status >= 0 && order.status < 3 ){%^>
	 <^%if(order.is_reback == 0 && order.is_make == 0 ){%^>
		  <^%if(order.paytype == 0 ){%^>
			 
				 
						<a 
						<^%if(order.paytype == 0 ){%^> 
							onclick="unorder('<^%=order.id%^>');"
						<^% }else{%^> 
							<^%if(order.paystatus == 0 ){%^>  onclick="unorder('<^%=order.id%^>');" href="javascript:void(0);"  <^% }else{%^>  href="<{ofunc type=url link="/wxsite/drawbacklog/orderid/<^%=order.id%^>"}>"  <^%}%^>
						<^%}%^>
						href="javascript:void(0);" >  <button class="red-back" data-node="add-comment">取消订单</button></a>
				 
	 
		<^%}%^>
		
					  <^%if(order.paytype ==1 && order.paystatus ==0){%^>
						  
									<a  onclick="unorder('<^%=order.id%^>');"  href="javascript:void(0);" >  <button class="red-back" data-node="add-comment">取消订单</button></a>
							 
					 
					<^%}%^>
					  <^%if(order.paytype ==1 && order.paystatus ==1 && order.is_make ==0 && order.is_reback == 0  ){%^>
						  
									<a    href="<{ofunc type=url link="/order/drawuserorder/orderid/<^%=order.id%^>"}>" >  <button class="red-back" data-node="add-comment">取消订单</button></a>
							 
					 
					<^%}%^>
	<^% }else{%^>
		 
		<^%if(order.is_reback == 1 ){%^>
			<a    href="<{ofunc type=url link="/order/drawuserorder/orderid/<^%=order.id%^>"}>" >  <button class="red-back" data-node="add-comment">查看退款详情</button></a>	
		<^%}%^>
	<^%}%^>	
<^%}%^>
 <^%if(order.status ==4 || order.status ==5){%^>
		 
					<a   href="<{ofunc type=url link="/site/index"}>" >  <button class="red-back" data-node="add-comment">逛逛别家</button></a>
		 
	 
<^%}%^>
 <^%if(order.status == 0 && order.paytype ==1 && order.paystatus == 0  ){%^>
 <a   href="<{ofunc type=url link="/site/waitpay/orderid/<^%=order.id%^>"}>" >  <button class="red-back" data-node="add-comment">继续支付</button></a>
<^%}%^>
 <^%if(order.status>= 0 && order.status  < 3 && order.is_make == 1 ){%^>

					<a   href="<{ofunc type=url link="/site/index"}>" >  <button class="red-back" data-node="add-comment">逛逛别家</button></a>
			<^%}%^>
<^%if(order.status == 2 && order.is_acceptorder == 0  ){%^>
<a  onclick="acceptorder('<^%=order.id%^>');"  href="javascript:void(0);" >  <button class="red-back" data-node="add-comment">确认收货</button></a>
<^%}%^>
<^%if(order.status == 3 && order.is_acceptorder == 1 && order.is_ping == 0  ){%^>
	<a  onclick="pingorder('<^%=order.id%^>');"  href="javascript:void(0);" >  <button class="red-back" data-node="add-comment">评价订单</button></a>
<^%}%^>
<^%if(order.status == 3 && order.is_acceptorder == 1 && order.is_ping == 1  ){%^>
	  <^%if(order.shoptype == 1   ){%^>
		<a class="cui-btn active"    href="<{ofunc type=url link="/market/shopshow/id/<^%=order.shopid%^>"}> "> <button class="red-back" data-node="add-comment">在来一单</button> </a> 
	  <^% }else{%^>
		<a class="cui-btn active"    href="<{ofunc type=url link="/shop/index/id/<^%=order.shopid%^>"}>" > <button class="red-back" data-node="add-comment">在来一单</button> </a> 
	 <^%}%^>
<^%}%^>
	
</div>
 
 
 
      
		  </div>
			</div>
		
		
		
		
        <div class="clear"></div>
      </div>
    </div>
  </div>
</div>
		
	</section>		
			





							<div class="clear"></div>
</script>
<script type="text/javascript">
	$(document).ready(function(){ 
		for(var i=0;i< $('.proleng').length;i++){
			var whatobj = $('.proleng').eq(i).find('.hover').length;
			whatobj = Number(whatobj)-1;
			var myobj =  $('.proleng').eq(i).find('.hover').eq(whatobj);
			//计算位置
			var cobj = $('.proleng').eq(i).find('.hover').eq(0);
				var menupos =$(myobj).offset();
        var leftend = menupos.left;
        var startpost = $(cobj).offset();
        var leftstart = startpost.left;
        var widths = Number(leftend)-Number(leftstart);
        $('.proleng').eq(i).find('.pro').eq(0).css('width',widths+'px'); 
		} 
	});
	function addAddr()
	{
		$('#newAddr_1').show();
	}
	function getOrderDetail(orderid)
	{  
	        var info = {'orderid':orderid};
	      	var backmes =   ajaxback('<{ofunc type=url link="/order/userorderdet/datatype/json"}>',info); 
	      	if(backmes.flag == false)
	      	{
	      		// $backinfo['order'] = $orderinfo;
		        //$backinfo['orderdet'] = $orderdetinfo;
		         $('#tempordershow').show();
	      		 var htmls = template.render('trgoodlist', {order:backmes.content.order,orderdet:backmes.content.orderdet,orderwuliustatus:backmes.content.orderwuliustatus});
	      	   $('#m3-order-detail').html(htmls); 
			   
			   $("#wuliustatus .line-through:last").hide();
			   
	      	}else{
	      		diaerror(backmes.content); 
	      	}  
	}
	function getOrders(){
		//
		var mlinks = '<{ofunc type=url link="/order/usersorder/status/@status@/stime/@stime@/etime/@etime@/orderdatediff/@orderdatediff@"}>';
		mlinks = mlinks.replace('@orderdatediff@', $("#orderdatediff").find("option:selected").val());
		mlinks = mlinks.replace('@status@', $('#orderstatus').find("option:selected").val());
		mlinks = mlinks.replace('@stime@', $('#stime').val());
		mlinks = mlinks.replace('@etime@', $('#etime').val());
	 window.location.href=mlinks;
	}
	function unorder(orderid)
	{
		if(confirm('确定取消订单吗？')){
		   myajax('<{ofunc type=url link="/order/userunorder/datatype/json"}>',{'orderid':orderid});
		}
	}
	function delorder(orderid)
	{
		if(confirm('确定删除订单吗？')){
		   myajax('<{ofunc type=url link="/order/userdelorder/datatype/json"}>',{'orderid':orderid});
		}
	}
	function compelte(orderid)
	{
		window.location.href= siteurl+'/index.php?ctrl=membercenter&action=pingorder&orderid='+orderid;
	} 
	 function acceptorder(orderid){  
	 	if(confirm('确认收货？')){
   	     $('#loading').show(); 
   		   var url = siteurl+'/index.php?ctrl=order&action=acceptorder&orderid='+orderid+'&datatype=json&random=@random@';   
 	        $.ajax({ 
           dataType: "json",  
           url: url.replace('@random@', 1+Math.round(Math.random()*1000)),  
           success: function(content) {    
           	 if(content.error == false) 
          	{  
          		$('#orderstatus').text('已关闭'); 
          		$('.cart_gojs').remove();
          		$('#loading').hide();
				window.location.reload();
				
          	}else{ 
          			alert(content.msg);
          		  $('#loading').hide();
          	}  
          	 
	         }, 
           error: function(content) {  
             	alert('提交数据失败');
        	    $('#loading').hide();
	         }
       
         });  
     }
     return false;
   }
   function pingorder(){
   		window.location.href=siteurl+'/index.php?ctrl=order&action=waitpiont';
  }
	
</script>
<{/block}>